{include file="common:header"}
<style>
    .status{position: absolute;top: 30%;left: 0px;width: 100%;text-align: center;}
    .status .icon{ margin: 0 auto 40px;width: 60px;height: 60px;background-color: #2869db;-webkit-border-radius: 100%;-moz-border-radius: 100%;-o-border-radius: 100%;border-radius: 100%;line-height: 54px;}
    .status .icon span{font-size: 50px;color: #fff;}
    .status p{font-size: 18px;line-height: 1;}
</style>
<body>
{if $check_num}
<div id="elufenfang-login2">
    <div class="login-bg">
        <img src="/static/images/login-bg.jpg">
        <img src="/static/images/login-mbg.jpg" class="m-bg">
    </div>
    <div class="login">
        <form name="main-login" action="{:url('Index/userBackLogin')}" method="post">
            <div class="login-info login-select">
                <label>省份<span>*</span></label>
                <select name="province_id" id="region_id">
                    <option value="0">请选择省份</option>
                    {foreach $provinces as $province}
                    <option value="{$province['region_id']}">{$province['region_name']}</option>
                    {/foreach}
                </select>
            </div>
            <div class="login-info login-select">
                <label>城市<span>*</span></label>
                <select name="city_id" id="city_id" >
                    <option value="">请选择城市</option>
                </select>
            </div>
            <div class="login-info login-select">
                <label>医院<span>*</span></label>
                <select name="hospital_id" id="hospital_id">
                    <option value="">请选择医院</option>
                </select>
            </div>
            <div class="login-info login-select">
                <label>科室<span>*</span></label>
                <select name="subject_id" id="subject_id">
                    <option value="">请选择科室</option>
                    {foreach $subjects as $subject}
                    <option value="{$subject['subject_id']}">{$subject['subject_name']}</option>
                    {/foreach}
                </select>
            </div>
            <div class="login-info login-text">
                <label>参会人数<span>*</span></label>
                <input type="text" name="count" id="count" placeholder="请填写参会人数" class="people-number">
            </div>
            <div class="login-info login-submit">
                <input type="hidden" name="user_name" value="{$check_num['user_name']}">
                <input type="hidden" name="user_email" value="{$check_num['user_email']}">
                <input type="submit" class="userlogin" value="登录"/>
            </div>
            <div class="clear"></div>
        </form>
    </div>
</div>
{else}
<div class="status">
    <div class="icon"><span>&times;</span></div>
    <div>
        <p>身份验证失败</p>
    </div>
</div>
{/if}
<script language="JavaScript">
    $(document).on('click', 'select[name="city_id"]', function(){
         if(!$(this).val()){
             layer.msg('请选择省份', {icon: 2});
         }
    })
    $(document).on('click', 'select[name="hospital_id"]', function(){
        if(!$(this).val()){
            layer.msg('请选择城市', {icon: 2});
        }
    });

    $('#region_id').change(function () {
        var region_id = $(this).val();
        var url = "{:url('index/getCity')}?province_id=" + region_id;
        $.get(url, function (obj) {
            if (obj) {
                var city_html = '<option value="0">请选择城市</option>';
                for (var i = 0, j = obj; i < j.length; i++) {
                    city_html += '<option value="' + j[i]['region_id'] + '">' + j[i]['region_name'] + '</option>';
                }
                $('#city_id').html(city_html);
            } else {
                layer.msg(obj.message, {icon: 2});
            }
        })
    });
    $('#city_id').change(function () {
        var region_id = $(this).val();
        var url = "{:url('index/getHospital')}?city_id=" + region_id;
        $.get(url, function (obj) {
            if (obj.length>0) {
                var city_html = '<option value="0">请选择医院</option>';
                for (var i = 0, j = obj; i < j.length; i++) {
                    city_html += '<option value="' + j[i]['hospital_id'] + '">' + j[i]['hospital_name'] + '</option>';
                }
                $('#hospital_id').html(city_html);
            } else {
                layer.msg('该市没有对应的医院', {icon: 2});
            }
        })
    });
</script>
</body>
